package listdemo;

import java.util.LinkedList;
import java.util.List;

public class LinkedListDemo {

    public static void main(String[] args) {

        List list = new LinkedList();
        list.add("grape");
        list.add("banana");
        list.add("apple");
        list.add("orange");
        list.add(null);
        list.add("watermelon");
        list.add("apple");

        for(Object obj : list){
            System.out.println(obj);
        }

        ((LinkedList) list).addFirst("pear");
        ((LinkedList) list).addLast("strawberry");

        System.out.println("---------添加头尾节点后----------");
        for(Object obj : list){
            System.out.println(obj);
        }
    }
}
